package me.zhenqu.redis.utils;

/**
 * Created by IntelliJ IDEA.
 * User: yibing.tan
 * Date: 11-11-14
 * Time: 下午4:20
 * To change this template use File | Settings | File Templates.
 */
public class ByteArrayCoder extends CacheCoder<byte[]> {

    public static final CacheCoder INST = new ByteArrayCoder();

    @Override
    public byte[] encode(byte[] o) {
        return o;
    }

    @Override
    public byte[] decode(byte[] val, int offset, int size) {
        if (offset == 0 && size == val.length) return val;
        byte[] b = new byte[size];
        System.arraycopy(b, offset, b, 0, size);
        return b;
    }
}
